import React from 'react'
import { Menu } from 'antd'
import logo from '../../assert/images/logo-ant.svg'
import menuList from './menuConfig'
import {Link,Redirect} from 'react-router-dom'
export default class test extends React.Component {
    constructor(props){
        super(props)
        this.state = {
            menuList:[]
        }
        console.log(props)
    }
    componentWillMount(){
        var a = this.getNavList(menuList)
        console.log(a)
        this.setState({
            menuList: a
        })
       
    }
    //加载菜单列表
    getNavList(list){
        return list.map((item)=>{
            if (item.children){
                return <Menu.SubMenu mode="vertical" title={item.title} key={item.key} >{this.getNavList(item.children)}</Menu.SubMenu>
            }else{
                return <Menu.Item mode="vertical" key={item.key} onClick={() => { this.pageJump(item.key) }}>{item.title}</Menu.Item>
            }
        })
    }
    //页面跳转
    pageJump = (pageCode)=>{
        this.props.history.push(pageCode)

       
    }
    render() {
        return (
            <div>
                <div className="nav-top">
                    <img src={logo} />
                    <h1>IMOOC</h1>
                </div>
                <Menu  mode="vertical" theme="dark">
                    {/* <Menu.SubMenu key="sub2" title={<span><span>Navigation Two</span></span>}>
                        <Menu.Item key="5">Option 5</Menu.Item>
                        <Menu.Item key="6">Option 6</Menu.Item>
                        <Menu.SubMenu key="sub3" title="Menu.SubMenu">
                            <Menu.Item key="7">Option 7</Menu.Item>
                            <Menu.Item key="8">Option 8</Menu.Item>
                        </Menu.SubMenu>
                    </Menu.SubMenu> */}
                    {this.state.menuList}
                </Menu>,
            </div>
        )
    }
}